
var isdata=0;
var typedata;
var pagindex=0;
var pagesize=10;
var itemIndex = 0;

mui('body').on('tap','a',function(){document.location.href=this.href;});
function createFragment(me,itemIndex) {
    var data ={
        pageindex:pagindex,
        pagesize:pagesize
    }

    var result = '';
    mui.post('/Article/findAll', data, function (info) {
        console.log(info);
        var datas = info.object;
        if(datas.length === 0){
            me.lock();
            me.noData();
            me.resetload();
            return;
        }else {
            for (var i = 0; i < datas.length; i++) {
                cold = datas[i];
                result
                    += ''
                    + '    <hgroup class="khfxRow">'
                    + '      <header>创建时间：'+formattime(cold['createtime'])+'</header>'
                    + '      <div class="mid">'
                    + '        <img class="photo" src="'+imgsrcpath()+cold['preimage']+'" >'
                    + '        <span><label>标题：</label>'+cold['title']+'</span> '
                    + '        <span><label>摘要：</label>'+cold['pretext']+'</span> '
                    + '      </div>'
                    + '      <footer style="height: 40px;">'+wxfenxbtn(cold['id'])+'</footer>'
                    + '    </hgroup>';
            }
            $('.khfxPane').eq(itemIndex).append(result);
            if(datas.length <10){
                me.$domDown.html(me.opts.domDown.domNoData);
                return;
            }
            else {
                me.resetload();
                me.$domDown.html(me.opts.domDown.domRefresh);
            }
            pagindex=pagindex+10;
            pagesize=pagesize+10;
        }
    });

};

function deletead(obj){
    var dataobj={
        id:obj
    }
    mui.post('/Article/delete',
        dataobj,
        function(data) {
            if (data.object>0)
            {
                mui.toast('提交成功！');
                window.location.reload();
            }
        },'json'
    )
}

$(function () {
    function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
    }

    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }
    var itemIndex = 0;
    var tabLoadEndArray = [false, false, false];
    var tabScroolTopArray = [0, 0, 0];
    // dropload
    var dropload = $('.khfxWarp').dropload({
        scrollArea: window,
        domDown: {
            domClass: 'dropload-down',
            domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
            domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData: '<div class="dropload-noData">已无数据</div>'
        },
        loadDownFn: function (me) {
            setTimeout(function () {
                createFragment(me, itemIndex);
            }, 500);
        }
    });



});